module.exports = function(grunt) {

    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),

        removelogging: {
            options: {
                //移除console.log等方法
                methods: ['warn', 'log', 'info']
            },
            main: {
                src: ['src/**/*.js', '!src/lib/']
            }
        },

        clean: {
            tmp: ['tmp']
        },

        copy: {
            main: {
                files: [{
                    expand: true,
                    cwd: 'src/',
                    src: ['**'],
                    dest: 'dist'
                }]
            }
        },

        transport: {
            options: {
                debug: false,
                //提取模块id的前缀
                idleading: '<%=pkg.name%>/',
                alias: {
                    'jquery': 'jquery'
                }
            },
            main: {
                files: [{
                    expand: true,
                    cwd: 'src/',
                    src: ['**/*.js'],
                    dest: 'tmp'
                }]
            }
        },

        concat: {
            options: {
                include: 'all',
                separator: ';',
                paths: ['dist']
            },
            main: {
                files: [{
                    expand: true,
                    cwd: 'tmp/',
                    src: ['**/*.js'],
                    dest: 'dist/<%=pkg.name%>'
                }]
            }
        },

        uglify: {
            main: {
                files: [{
                    expand: true,
                    cwd: 'dist/<%=pkg.name%>',
                    src: ['**/*.js'],
                    dest: 'dist/<%=pkg.name%>'
                }]
            }
        }
    });

    grunt.loadNpmTasks('grunt-contrib-copy');
    grunt.loadNpmTasks('grunt-cmd-transport');
    grunt.loadNpmTasks('grunt-cmd-concat');
    grunt.loadNpmTasks("grunt-remove-logging");
    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.loadNpmTasks('grunt-contrib-uglify');

    grunt.registerTask('default', ['transport', 'concat', 'uglify', 'clean']);
}
